﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI.WebControls;

namespace Sasc.PV.Web
{
    public class LookupHyperLink : HyperLink
    {
        public LookupHyperLink()
        {
            DialogResizable = false;
            MergeValue = false;
        }

        protected override void OnLoad(EventArgs e)
        {
            CssClass = "lookupbutton";
            Text = "&nbsp;";

            base.OnLoad(e);

            Attributes.Add("data-lookupotions", WebUtils.JsonEncode(new
            {
                DialogURL = ResolveClientUrl(DialogURL),
                DialogWidth = DialogWidth + "px",
                DialogHeight = DialogHeight + "px",
                LookupTarget = LookupTarget,
                MergeValue = MergeValue,
                DialogResizable = DialogResizable,
                OriginalValue = OriginalValue
            }));
        }

        /// <summary>
        /// 
        /// </summary>
        public bool MergeValue { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int DialogWidth { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int DialogHeight { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string DialogURL { get; set; }

        /// <summary>
        /// JQuery selector, don't support Control ID
        /// </summary>
        public string LookupTarget { get; set; }

        public bool DialogResizable { get; set; }

        public string OriginalValue { get; set; }
    }
}